<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>字符串缩进</title>
</head>
<body>
  <script>
    const book = {
      title: 'Professional JavaScript',
      authors: [
        'Nicholas C. Zakas',
        'Matt Frisbie'
      ],
      edition: 4,
      year: 2017
    };
    const jsonText = JSON.stringify(book, null, 4);

    console.log(jsonText);
    /* 
    {
        "title": "Professional JavaScript",
        "authors": [
            "Nicholas C. Zakas",
            "Matt Frisbie"
        ],
        "edition": 4,
        "year": 2017
    }
     */
  </script>
</body>
</html>